﻿using System;
using System.Collections.Generic;
using SCG.SolarVengeanceEngine;

namespace SCG.SolarVengeance.Scenarios
{
    public class Sprawling : Scenario
    {
        //constructor
        public Sprawling()
        {
            spMapWidth = CreateParameter("Map Width", 100, 50, 200);
            spMapHeight = CreateParameter("Map Height", 100, 50, 200);
            spStars = CreateParameter("StarSystems", 30, 10, 100);
            spNebula = CreateParameter("Nebulae", 4, 0, 10);
            spNebArms = CreateParameter("Nebula Arms", 4, 1, 20);
            spNebCells = CreateParameter("Nebula Cells", 50, 1, 500);
            spWormholes = CreateParameter("Wormholes", 4, 0, 20);
            spBlackHoles = CreateParameter("Black Holes", 2, 0, 20);
            spPulsars = CreateParameter("Pulsars", 2, 0, 20);
        }

        //allow more players
        public override int MaxPlayers
        {
            get
            {
                return 20;
            }
        }

        //scenario build logic
        public override void BuildScenario(int numPlayers, int capitalValues, int startingResources)
        {
            //Create StarSystems
            int w = spMapWidth.Value;
            int h = spMapHeight.Value;
            int midx = spMapWidth.Value / 2;
            int midy = spMapHeight.Value / 2;
            CreateStarCluster(spStars.Value, midx, midy, midx, midy, midx, 1);

            //Create Nebula
            for(int n = 0; n < spNebula.Value; n++)
                CreateNebula(Random(0, w - 1), Random(0, h - 1), spNebArms.Value, spNebCells.Value);          

            //Create other cosmic phenomenon
            for (int wh = 0; wh < spWormholes.Value; wh++)
                CreateWormhole(Random(0, w - 1), Random(0, h - 1), Random(0, w - 1), Random(0, h - 1));
            for (int b = 0; b < spBlackHoles.Value; b++)
                CreateBlackHole(Random(0, w - 1), Random(0, w - 1), Random(5, 20));
            for (int p = 0; p < spPulsars.Value; p++)
                CreatePulsar(Random(0, w - 1), Random(0, h - 1));
        }

        //Map size
        public override int MapWidth
        {
            get
            {
                return spMapWidth.Value;
            }
        }
        public override int MapHeight
        {
            get
            {
                return spMapHeight.Value;
            }
        }

        //description
        public override string Description
        {
            get
            {
                return "Sprawing is set in a loose cluster where StarSystems are evenly distributed.  " +
                    "It includes a variety of cosmic terrain to make each game different and interesting.  " +
                    "Sprawling exposes many parameters that you can tweak before starting the game.";
            }
        }

        //parameters
        private ScenarioParameter spStars;
        private ScenarioParameter spMapWidth;
        private ScenarioParameter spMapHeight;
        private ScenarioParameter spNebula;
        private ScenarioParameter spNebArms;
        private ScenarioParameter spNebCells;
        private ScenarioParameter spWormholes;
        private ScenarioParameter spBlackHoles;
        private ScenarioParameter spPulsars;
    }
}
